

function join(){
	//var userName = dwr.util.getValue("userName");
	GameCenter.join("Room2");
	
}
 function loadDeck(){
	 document.getElementById("body").innerHTML =" Waiting for start......"
 }

function sendCard(){
	selectedUser = document.getElementById("users").value;
	//selectedCards = document.getElementById("card");
	//var cards[] = {1,2};
	var cards=new Array();
	cards[0]="1";
	cards[1]="2"
	GameCenter.sendCard(selectedUser, cards );
}

function cardRecieveAck(){
	
}
function initializeDeck(){
	//DWREngine.setAsync(false);
	dwr.util.setValue("cards" ,"waiting to start ");
	GameCenter.initGameDeck();
	//alert("After GameCenter.initGameDeck()");
}

function gameStartOption(){
	alert("start game");
	document.getElementById('body').innerHTML='<input type="button" value="Click" onclick="startGame()" />';
}
function startGame(){
	GameCenter.startGame();
}
function drawCards(cards){
	if(cards == null){
		
		
	}else{
		 myCards = cards['CARDS'];
		 users = cards['USERS'];
		var cardsDeck ="";
		//for ( var card in myCards ){
		for(var i=0;i<myCards.length; i++){
			//cardsDeck = cardsDeck + "<div>"+card+'<input type="checkbox" value="'+card+ '" name="card"> </div>';
			cardsDeck = cardsDeck + addCardToDeck(myCards[i].cardName);
		}
		cardsDeck = cardsDeck+ getUsersDropDown(users);;
		cardsDeck = cardsDeck+ '<input type="button" value="send cards" onclick="sendCard()> ';
		document.getElementById('body').innerHTML= cardsDeck;
	}
}

function addCardToDeck(card){
	var cardHtml = "<div>";
	cardHtml = cardHtml+ card;
	cardHtml = cardHtml+ '<input type="checkbox" value="'+card+ '" name="card" "> ';
	
	cardHtml = cardHtml+ "</div>";
	return cardHtml;
}

function getUsersDropDown(users){
	var cardHtml = '<select id="users">';
	//for ( var user in users ){
	for(var i=0;i<users.length; i++){
		cardHtml = cardHtml+ '<option value="'+users[i].userName+ '">'+users[i].userName+'</option> ';
	}
	cardHtml = cardHtml + '</select>';
	return cardHtml;
}

function displayUsers(){
	alert("aqw");
	
}




function isSendCard(str){
	if (confirm(str)) { 
 		
	}
	
}


